package com.multitrack.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import com.multitrack.R;

public class TemplateSelectionActivity extends AppCompatActivity {

    private Spinner spinnerTemplate;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_template_selection);

        spinnerTemplate = findViewById(R.id.spinner_template);

        // 菜单项
        String[] items = {"剪同款", "书单", "主题"};

        // 自定义Adapter
        ArrayAdapter<String> adapter = new ArrayAdapter<>(
                this,
                R.layout.item_spinner_template,
                R.id.tv_spinner_item,
                items
        );

        // 下拉菜单的样式
        adapter.setDropDownViewResource(R.layout.item_spinner_dropdown);
        spinnerTemplate.setAdapter(adapter);

        // 默认选中第一项
        spinnerTemplate.setSelection(0);

        // 处理选择事件
        spinnerTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                Toast.makeText(TemplateSelectionActivity.this,
                        "已选择: " + items[position], Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {
            }
        });
    }
} 